const joi = require("joi");
const { param } = require("../routes/area");

const areaName = joi.string().required();
const sort = joi.number().integer().allow(null);
const picUrl = joi.string().allow("").allow(null);
const parentId = joi
  .number()
  .integer()
  .allow(...[null, ""]);
const id = joi.number().integer().required();

// 注册表单的验证规则对象
exports.reg_area_add_schema = {
  // 对 req.body 中的数据进行验证
  body: {
    areaName,
    sort,
    picUrl,
    parentId,
  },
};
// 删除
exports.reg_area_delete_schema = {
  params: {
    id,
  },
};

// 注册表单的验证规则对象
exports.reg_area_edit_schema = {
  // 对 req.body 中的数据进行验证
  body: {
    id,
    areaName,
    sort,
    picUrl,
    parentId,
  },
};
